package com.sky.context;

public class BaseContext {
    // 线程变量,用于保存当前请求的id,不同用户开启一条线程来区别不同用户
    public static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    // 设置当前请求用户的id
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    // 获取当前请求用户的id
    public static Long getCurrentId() {
        return threadLocal.get();
    }

    // 清除当前请求用户的id
    public static void removeCurrentId() {
        threadLocal.remove();
    }
}
